package com.yypinger.gxonline.view.clothmanager;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.appfoundation.i18n.Lang;

import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.VerticalSplitPanel;
import com.yypinger.gxonline.IGxOnlineApplication;
import com.yypinger.gxonline.entities.Order;
import com.yypinger.gxonline.entities.User;
import com.yypinger.gxonline.ordermanager.IOrderManager;
import com.yypinger.gxonline.ordermanager.OrderProcessedListener;

public class ReceiveClothView extends VerticalSplitPanel implements IOrderManager , ValueChangeListener , ClickListener{

	private static final long serialVersionUID = -8463610335423347583L;

	@Autowired
	private IOrderManager ordermanager;
	
	//订单列表
	private ClothOrderList orderList;
	
	//订单明细列表，主要显示摸一个订单的相关信息
	private ClothOrderItemList orderItemList;
	
	//创建订单按钮
	private Button createOrderBtn = new Button(Lang.getMessage("createOrderBtn"));
	//取衣按钮
	private Button takeClothBtn = new Button(Lang.getMessage("takeClothBtn"));
	//撤销单子
	private Button clearOrderBtn = new Button(Lang.getMessage("clearOrderBtn"));
	//重洗衣物
	private Button renewOrderBtn = new Button(Lang.getMessage("renewOrderBtn"));
	//赔付衣物
	private Button amendsOrderBtn = new Button(Lang.getMessage("amendsOrderBtn"));
	
	private IGxOnlineApplication app;
	/**
	 * 构造函数
	 */
	public  ReceiveClothView(IGxOnlineApplication application){
		this.app = application;
		buildManiLayout();
	}
	
	/**
	 * 拼装订单管理界面
	 */
	private void buildManiLayout(){
		//VerticalSplitPanel layout = new VerticalSplitPanel();
		setStyleName("main-split");
        setSizeFull();
        orderList = new ClothOrderList(this);
        addComponent(orderList);
        orderItemList = new ClothOrderItemList();
        addComponent(orderItemList);
	}
	
	@Override
	public List<Order> getAllOrder(User user) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public void valueChange(ValueChangeEvent event) {
		 Property property = event.getProperty();
	        if (property == orderList) {
	            Item item = orderList .getItem(orderList.getValue());
	        }
	}
	@Override
	public void buttonClick(ClickEvent event) {
		final Button source = event.getButton();
		if(source == createOrderBtn){
			
		}else if(source == takeClothBtn){
			
		}else if(source == clearOrderBtn){
			
		}else if(source == renewOrderBtn){
			
		}else if(source == amendsOrderBtn){
			
		}
		
	}
	
}
